package com.example.duomeitijuhe.ui;

import android.app.Activity;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.util.Log;
import android.widget.ImageButton;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.ImageRequest;
import com.android.volley.toolbox.Volley;
import com.example.duomeitijuhe.R;
import com.example.duomeitijuhe.bean.GetInternetDataBean;
import com.example.duomeitijuhe.dao.LoadPictures;
import com.example.duomeitijuhe.others.ReducePicture;
import com.example.duomeitijuhe.others.RoundPicture;

/**
 * Created by Michael on 2014/10/15.
 */
public class TestActivity extends Activity {

    ImageButton headImageButton;
    LoadPictures loadPictures;

    ReducePicture reducePicture;
    RoundPicture roundPicture;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.weibo_of_list_view);
        loadPictures = new LoadPictures();
        headImageButton = (ImageButton)findViewById(R.id.sender_head_icon_button);
        Bitmap headBitmap = loadPictures.returnHeadBitmap("http://tp3.sinaimg.cn/1720084970/50/40063731097/1");


        //Bitmap headBitmap = loadPictures.loadHeadPicture("http://tp3.sinaimg.cn/1720084970/50/40063731097/1");
        //Log.e("headBigmap",head)
        headImageButton.setImageBitmap(headBitmap);

        /*reducePicture = new ReducePicture(this);
        roundPicture = new RoundPicture();
        RequestQueue requestQueue = Volley.newRequestQueue(this);
        ImageRequest imageRequest = new ImageRequest("http://tp3.sinaimg.cn/1720084970/50/40063731097/1",
                new Response.Listener<Bitmap>() {
                    @Override
                    public void onResponse(Bitmap bitmap) {
                        Bitmap headIconBitmap = roundPicture.toRoundBitmap(bitmap);
                        headImageButton.setImageBitmap(headIconBitmap);
                    }
                },
                40,40, Bitmap.Config.ARGB_8888,
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError volleyError) {
                        Bitmap bitmap = reducePicture.pictureToLess(R.drawable.ic_launcher,40);
                        Bitmap headIconBitmap = roundPicture.toRoundBitmap(bitmap);
                        headImageButton.setImageBitmap(headIconBitmap);
                    }
                }
        );

        requestQueue.add(imageRequest);*/
    }
}
